package org.example.module_teacher.utlis;

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class JWTTokenVerify {

    private static final String baseUrl = "http://localhost:8084/jwtTokenVerify";

    public static boolean jwtTokenVerify(String token){
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(baseUrl))
                .header("Authorization", token)
                .GET()
                .build();
        try {
            // 发送请求并获取响应
            HttpResponse<String> responseJwt = client.send(request, HttpResponse.BodyHandlers.ofString());
            return responseJwt.statusCode() == 200;
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
            return false;
        }
    }

}
